<template>
  <!-- 工单升级提醒配置 -->
  <el-upload
    accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    :action="prop_upload_url"
    :on-success="fileUploadSuccess"
    :on-error="fileUploadError"
    :disabled="fileUploadBtnText==='正在导入'"
    :before-upload="beforeFileUpload"
    :show-file-list="false"
    style="display: inline;margin-left: 10px;margin-right: 10px">
    <el-button size="medium" type="primary" :loading="fileUploadBtnText==='正在导入'">{{fileUploadBtnText}}</el-button>
  </el-upload>
</template>

<script>
  export default {
    name: "uploadExcel",
    components: {},
    /*head() {
      return {
        title: "上传Excel模板",
        meta: [
          {hid: 'description', name: 'about', content: '上传Excel模板'}
        ]
      }
    },*/
    data() {
      return {
        //导入时按钮字体
        fileUploadBtnText: '批量导入',
      };
    },
    props: {
      prop_upload_url: {   //请求地址
        require: true
      },
    },
    created() {
    },
    mounted() {

    },
    watch: {},
    methods: {
      //导入成功回调
      fileUploadSuccess(response, file, fileList) {
        this.fileUploadBtnText = '批量导入';
        this.$emit('sucessCallback', response);
      },
      //导入失败回调
      fileUploadError(err, file, fileList) {
        this.fileUploadBtnText = '批量导入';
        this.$emit('errorCallback', response);
      },
      beforeFileUpload(file) {
        this.fileUploadBtnText = '正在导入';
      },
    }
  }
</script>

<style scoped lang="scss">

</style>
